function [pos0, pos] = fixposition(XlocA,XlocB,ZlocA,ZlocB,...
    XwidA,XwidB,ZwidA,ZwidB)
%======================================================================
%  [pos0, pos] = FIXPOSITION(XlocA, XlocB, ZlocA, ZlocB, XwidA, XwidB,
%                    ZwidA,ZwidB)
%
%  The function FIXPOSITION adjusts the location of a plot or subplot 
%    relative to the original position:
%  
%    pos0 = original position
%    pos = new position
%        = [pos0(1)*XlocA + XlocB, pos0(2)*ZlocA + ZlocB,
%           pos0(3)*XwidA + XwidB, pos0(4)*ZwidA + ZwidB]
%
%  Written by Mark Behn, March 2004
%======================================================================

pos0 = get(gca,'Position');

pos = [pos0(1)*XlocA+XlocB,pos0(2)*ZlocA+ZlocB,pos0(3)*XwidA+XwidB,...
      pos0(4)*ZwidA+ZwidB];

set(gca,'Position',pos);


